package com.mflex.mwms.manager;

import com.mflex.mwms.model.DeviceLoginRequest;
import com.mflex.mwms.model.User;

public class TokenManager {
    private static TokenManager sInstance;

    private String mToken = "";
    /**
     * 当前登录的用户
     */
    private DeviceLoginRequest mLoginUser;

    private TokenManager() {

    }

    public static TokenManager getInstance() {
        if (sInstance == null) {
            synchronized (TokenManager.class) {
                if (sInstance == null) {
                    sInstance = new TokenManager();
                }
            }
        }
        return sInstance;
    }

    public TokenManager setToken(String token) {
        mToken = token;
        return this;
    }

    public String getToken() {
        return mToken;
    }

    public DeviceLoginRequest getLoginUser() {
        return mLoginUser;
    }

    public boolean isUserLogined() {
        return mLoginUser != null;
    }

    public TokenManager setLoginUser(DeviceLoginRequest loginUser) {
        mLoginUser = loginUser;
        return this;
    }
}
